import requests

url = 'https://www.pearvideo.com/video_1759035'
contId = url.split('_')[1]

videoStatus_url = f'https://www.pearvideo.com/videoStatus.jsp?contId={contId}&mrd=0.31268703687854704'
# referer: 为防盗链,溯源 ——> 当前本次请求的上一级是谁
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36",
    "Referer": url
}
res = requests.get(videoStatus_url,headers=headers)
dict = res.json()
srcUrl =dict['videoInfo']['videos']['srcUrl']
systemTime = dict['systemTime']

src_url =srcUrl.replace(systemTime,f'cont-{contId}')
# print(src_url)

# 下载视频
with open(r'D:\ui\reptile\cookie_deal\data\video.mp4','wb') as f:
    f.write(requests.get(src_url).content)

res.close()

print('over!')
# https://video.pearvideo.com/mp4/adshort/20220418/cont-1759035-15863820_adpkg-ad_hd.mp4
# https://video.pearvideo.com/mp4/adshort/20220418/1650383221529-15863820_adpkg-ad_hd.mp4



